Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - [VB.NET] PDF Creator, 1 pagina alla volta
Forum - C# / VB.NET - [VB.NET] PDF Creator, 1 pagina alla volta

Avatar
()
Newbie


Messaggi:
Iscritto:

Segnala al moderatore
Postato alle 1:00
Giovedì, 01/01/1970
Ciao a tutti!

Alla fine del post trovate il codice che utilizzo per stampare
tramite la stampante virtuale di PDF Creator, un file jpg
(utilizzo questo metodo perchè per il momento è l'unico che conosco
per poter convertire una pagina pdf in jpg).

Il problema di questo codice è il seguente :

PDF Creator stampa in jpg 1 pagina alla volta, quindi
se stampo un pdf da 10 pagine lui stamperà sempre e solo la prima
pagina....

Come potrei dare in pasto a pdf una determinata pagina del pdf?

Grazie

Codice sorgente - presumibilmente VB.NET

  1. Private Sub PrintIt(ByVal Filetyp As Long)
  2.         Dim fname As String, fi As FileInfo, DefaultPrinter As String
  3.         Dim opt As PDFCreator.clsPDFCreatorOptions
  4.         Dim test As PDFCreator.clsUpdate
  5.         fi = New FileInfo(OpenFileDialog1.FileName)
  6.         If fi.Name.Length > 0 Then
  7.             If InStr(fi.Name, ".", CompareMethod.Text) > 1 Then
  8.                 fname = Mid(fi.Name, 1, InStr(fi.Name, ".", CompareMethod.Text) - 1)
  9.             Else
  10.                 fname = fi.Name
  11.             End If
  12.         End If
  13.  
  14.         If Not _PDFCreator.cIsPrintable(fi.FullName) Then
  15.             MsgBox("File '" & fi.FullName & "' is not printable!", MsgBoxStyle.Exclamation, Me.Text)
  16.             Exit Sub
  17.         End If
  18.         opt = _PDFCreator.cOptions
  19.         With opt
  20.             .UseAutosave = 1
  21.             .UseAutosaveDirectory = 1
  22.             .AutosaveDirectory = fi.DirectoryName
  23.             .AutosaveFormat = 2
  24.             .JPEGQuality = 100
  25.             .JPEGResolution = 150
  26.             opt.AutosaveFilename = fname
  27.         End With
  28.         With _PDFCreator
  29.             .cOptions = opt
  30.             .cClearCache()
  31.             DefaultPrinter = .cDefaultPrinter
  32.             .cDefaultPrinter = "PDFCreator"
  33.             .cPrintFile(fi.FullName)
  34.             ReadyState = False
  35.             .cPrinterStop = False
  36.         End With
  37.  
  38.         With Timer1
  39.             .Interval = maxTime * 1000
  40.             .Enabled = True
  41.             Do While Not ReadyState And .Enabled
  42.                 Application.DoEvents()
  43.             Loop
  44.             .Enabled = False
  45.         End With
  46.         If Not ReadyState Then
  47.             MsgBox("Creating printer test page as pdf." & vbCrLf & vbCrLf & _
  48.              "An error is occured: Time is up!", MsgBoxStyle.Exclamation, Me.Text)
  49.         End If
  50.         _PDFCreator.cPrinterStop = True
  51.         _PDFCreator.cDefaultPrinter = DefaultPrinter
  52.         opt = Nothing
  53.     End Sub


PM Quote